package com.ruoyi.web.controller.position;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.position.domain.RyssHistory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.position.domain.Ryss;
import com.ruoyi.position.service.IRyssService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员定位-实时数据Controller
 *
 * @author hcc
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/control/ryss")
public class RyssController extends BaseController
{
    @Autowired
    private IRyssService ryssService;

    /**
     * 查询人员定位-实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ryss ryss)
    {
        startPage();
        List<Ryss> list = ryssService.selectRyssList(ryss);
        return getDataTable(list);
    }
    /**
     * 查询人员定位-基站历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listJZHistory")
    public  List<Ryss> listJZHistory(Ryss ryss)
    {
        List<Ryss> list = ryssService.listJZHistory(ryss);
        return list;
    }
    /**
     * 查询人员定位-区域历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listQYHistory")
    public  List<Ryss> listQYHistory(Ryss ryss)
    {
        List<Ryss> list = ryssService.listQYHistory(ryss);
        return list;
    }
    /**
     * 查询人员定位-实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listArr")
    public List<Ryss> listArr(Ryss ryss)
    {
        List<Ryss> list = ryssService.selectRyssListALLSS(ryss);
        return list;
    }
    /**
     * 查询人员定位-历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listArrHistory")
    public List<Ryss> listArrHistory(Ryss ryss)
    {
        List<Ryss> list = ryssService.listArrHistory(ryss);
        return list;
    }
    /**
     * 查询人员定位-实时数据列表通过区域code
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listByCode")
    public List<Ryss> listByCode(Ryss ryss)
    {
        List<Ryss> list = ryssService.selectRyssListByQYCode(ryss);
        return list;
    }
    /**
     * 查询人员定位-实时数据列表通过JZcode
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:list')")
    @GetMapping("/listByJZCode")
    public List<Ryss> listByJZCode(Ryss ryss)
    {
        List<Ryss> list = ryssService.selectRyssListByJZCode(ryss);
        return list;
    }
    /**
     * 导出人员定位-实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:export')")
    @Log(title = "人员定位-实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Ryss ryss)
    {
        List<Ryss> list = ryssService.selectRyssList(ryss);
        ExcelUtil<Ryss> util = new ExcelUtil<Ryss>(Ryss.class);
        util.exportExcel(response, list, "人员定位-实时数据数据");
    }

    /**
     * 获取人员定位-实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:query')")
    @GetMapping(value = "/{positionRealtimeId}")
    public AjaxResult getInfo(@PathVariable("positionRealtimeId") String positionRealtimeId)
    {
        return success(ryssService.selectRyssByPositionRealtimeId(positionRealtimeId));
    }

    /**
     * 获取人员定位-实时数据详细DTO
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:query')")
    @GetMapping(value = "/getRyssDto/{positionPersonCode}")
    public AjaxResult getRyssDto(@PathVariable("positionPersonCode") String positionPersonCode)
    {
        return success(ryssService.getRyssDto(positionPersonCode));
    }
    /**
     * 新增人员定位-实时数据
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:add')")
    @Log(title = "人员定位-实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ryss ryss)
    {
        return toAjax(ryssService.insertRyss(ryss));
    }

    /**
     * 修改人员定位-实时数据
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:edit')")
    @Log(title = "人员定位-实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ryss ryss)
    {
        return toAjax(ryssService.updateRyss(ryss));
    }

    /**
     * 删除人员定位-实时数据
     */
    @PreAuthorize("@ss.hasPermi('control:ryss:remove')")
    @Log(title = "人员定位-实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{positionRealtimeIds}")
    public AjaxResult remove(@PathVariable String[] positionRealtimeIds)
    {
        return toAjax(ryssService.deleteRyssByPositionRealtimeIds(positionRealtimeIds));
    }

//    //井下总人
//    @GetMapping("/getAll")
//    public List<Ryss> getAll()
//    {
//        List<Ryss> list = ryssService.getAll();
//        return list;
//    }


    /**
     * 当前井下总人
     * @return
     */
    @GetMapping("/getAll")
    public int getAll()
    {
        int i = ryssService.getAll();
        return i;
    }



    /**
     * 井下领导数量
     * @return
     */
    @GetMapping("/getLd")
    public int getLd()
    {
        int i = ryssService.getLd();
        return i;
    }

    /**
     * 当前领导数
     * @return
     */
    @GetMapping("/getNowLd")
    public int getNowLd()
    {
        int i = ryssService.getNowLd();
        return i;
    }



    /**
     * 当日下井总人数
     */
    @GetMapping("/getTodayTotal")
    public int getTodayTotal(Ryss ryss)
    {
        int total = ryssService.getTodayTotal();
        return total;
    }
}
